package org.jeecg.modules.htxincailiao.patent.entity;

import java.io.Serializable;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.math.BigDecimal;
import java.util.List;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.jeecg.common.util.oConvertUtils;
import org.springframework.format.annotation.DateTimeFormat;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.jeecg.common.aspect.annotation.Dict;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

/**
 * @Description: ht_patent_supply
 * @Author: jeecg-boot
 * @Date:   2022-07-14 09:48:59
 * @Version: V1.0
 */
@Data
@TableName("ht_patent_supply")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@ApiModel(value="ht_patent_supply对象", description="ht_patent_supply")
public class HTPatentSupply implements Serializable {
    private static final long serialVersionUID = 1L;

	/**主键*/
	@TableId(type = IdType.ASSIGN_ID)
    @ApiModelProperty(value = "主键")
    private String id;
	/**企业ID*/
	@Excel(name = "企业ID", width = 15, dictTable = "ht_merchant", dicText = "enterprise_name", dicCode = "id")
	@Dict(dictTable = "ht_merchant", dicText = "enterprise_name", dicCode = "id")
    @ApiModelProperty(value = "企业ID")
    private String shopId;
	/**分类ID*/
	@Excel(name = "分类ID", width = 15, dictTable = "ht_patent_category", dicText = "name", dicCode = "id")
	@Dict(dictTable = "ht_patent_category", dicText = "name", dicCode = "id")
    @ApiModelProperty(value = "分类ID")
    private String categoryId;
	/**专利名称*/
	@Excel(name = "专利名称", width = 15)
    @ApiModelProperty(value = "专利名称")
    private String name;
	/**副标题*/
	@Excel(name = "副标题", width = 15)
    @ApiModelProperty(value = "副标题")
    private String subname;
	/**排序*/
	@Excel(name = "排序", width = 15)
    @ApiModelProperty(value = "排序")
    private Integer sort;

	/**
	 * 视频
	 */
	@Excel(name = "视频", width = 15)
	@ApiModelProperty(value = "视频")
	private String videoUrls;

	/**首页排序*/
	@Excel(name = "首页排序", width = 15)
    @ApiModelProperty(value = "首页排序")
    private Integer homeSort;
	/**专利号*/
	@Excel(name = "专利号", width = 15)
    @ApiModelProperty(value = "专利号")
    private String patentNumber;
	/**交易费*/
	@Excel(name = "交易费", width = 15)
    @ApiModelProperty(value = "交易费")
    private BigDecimal transactionFee;
	/**授权方式(0-专利转让，1-挂牌交易)*/
	@Excel(name = "授权方式(0-专利转让，1-挂牌交易)", width = 15, dicCode = "patent_authorization_method")
	@Dict(dicCode = "patent_authorization_method")
    @ApiModelProperty(value = "授权方式(0-专利转让，1-挂牌交易)")
    private Integer authorizationMethod;
	/**关键字*/
	@Excel(name = "关键字", width = 15)
    @ApiModelProperty(value = "关键字")
    private String keywords;
	/**描述*/
	@Excel(name = "描述", width = 15)
    @ApiModelProperty(value = "描述")
    private String description;
	/**详细内容*/
	@Excel(name = "详细内容", width = 15)
    @ApiModelProperty(value = "详细内容")
    private String content;
	/**主图*/
	@Excel(name = "主图", width = 15)
    @ApiModelProperty(value = "主图")
    private String cover;
	/**图片集*/
	@Excel(name = "图片集", width = 15)
    @ApiModelProperty(value = "图片集")
    private String images;
	/**是否为首页推荐 0-不推荐 1-推荐*/
	@Excel(name = "是否为首页推荐 0-不推荐 1-推荐", width = 15, dicCode = "is_home_recommended")
	@Dict(dicCode = "is_home_recommended")
    @ApiModelProperty(value = "是否为首页推荐 0-不推荐 1-推荐")
    private Integer isHomeRecommended;
	/**供应状态（状态 -1-下架,1-上架,2-预售,0-未上架）*/
	@Excel(name = "供应状态（状态 -1-下架,1-上架,2-预售,0-未上架）", width = 15, dicCode = "patent_supply_status")
	@Dict(dicCode = "patent_supply_status")
    @ApiModelProperty(value = "供应状态（状态 -1-下架,1-上架,2-预售,0-未上架）")
    private String supplyStatus;
	/**询价企业数*/
	@Excel(name = "询价企业数", width = 15)
    @ApiModelProperty(value = "询价企业数")
    private Integer inquiryEnterpriseCount;
	/**发布日期*/
	@Excel(name = "发布日期", width = 15, format = "yyyy-MM-dd HH:mm:ss")
	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "发布日期")
    private Date releaseDate;
	/**截止日期（不选择即为不截止）*/
	@Excel(name = "截止日期（不选择即为不截止）", width = 15, format = "yyyy-MM-dd HH:mm:ss")
	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "截止日期（不选择即为不截止）")
    private Date expireDate;
	/**审批人*/
	@Excel(name = "审批人", width = 15)
    @ApiModelProperty(value = "审批人")
    private String auditUsername;
	/**审核状态*/
	@Excel(name = "审核状态", width = 15, dicCode = "audit_status")
	@Dict(dicCode = "audit_status")
    @ApiModelProperty(value = "审核状态")
    private Integer auditStatus;
	/**审批意见*/
	@Excel(name = "审批意见", width = 15)
    @ApiModelProperty(value = "审批意见")
    private String auditComments;
	/**创建人*/
    @ApiModelProperty(value = "创建人")
    private String createBy;
	/**创建时间*/
	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "创建时间")
    private Date createTime;
	/**更新人*/
    @ApiModelProperty(value = "更新人")
    private String updateBy;
	/**更新时间*/
	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
	@ApiModelProperty(value = "更新时间")
	private Date updateTime;


	@TableField(exist = false)
	private Integer pageNo=1;

	@TableField(exist = false)
	private Integer pageSize=10;

	@TableField(exist = false)
	private String categoryName;

	@TableField(exist = false)
	private String authorizationMethodName;

	public String getAuthorizationMethodName() {
		if(oConvertUtils.isNotEmpty(this.authorizationMethod )) {
			switch (this.authorizationMethod) {
				case 1 :
					return "专利转让";
				case 2 :
					return "挂牌交易";
				default:
					return "普通许可";
			}
		}
		else {
			return "普通许可";
		}

	}

	@TableField(exist = false)
	private String[] imageList;

	public String[] getImageList() {
		String[] empty = new String[]{};

		if (oConvertUtils.isEmpty(images)) {
			return new String[]{cover};
		} else {
			List<String> combineList = new ArrayList<>();
			combineList.add(cover);

			String[] imageItems = images.split(",");
			List<String> imageList = Arrays.asList(imageItems);
			if (oConvertUtils.isNotEmpty(imageList) && !imageList.isEmpty()) {
				combineList.addAll(imageList);
			}

			return combineList.toArray(new String[0]);
		}
	}

	@TableField(exist = false)
	private String[] videoList;

	public String[] getVideoList() {
		String[] empty = new String[]{};

		if (oConvertUtils.isNotEmpty(videoUrls)) {
			String[] videoItems = videoUrls.split(",");

			List<String> list = Arrays.asList(videoItems);

			return list.toArray(new String[0]);
		}

		return empty;
	}

	@TableField(exist = false)
	private String[] mediaList;

	public String[] getMediaList() {
		List<String> list = new ArrayList<>();

		if (oConvertUtils.isNotEmpty(videoUrls)) {
			String[] videoItems = videoUrls.split(",");
			if (oConvertUtils.isNotEmpty(videoItems)) {
				list.addAll(Arrays.asList(videoItems));
			}
		} else {
			list.add(cover);
		}

		if (oConvertUtils.isNotEmpty(images)) {
			String[] imageItems = images.split(",");
			List<String> imageList = Arrays.asList(imageItems);
			if (oConvertUtils.isNotEmpty(imageList) && !imageList.isEmpty()) {
				list.addAll(imageList);
			}
		}

		return list.toArray(new String[0]);
	}


	@TableField(exist = false)
	private String poster;

	public String getPoster() {
		return cover;
	}

	/**SEO关键字*/
	@Excel(name = "SEO关键字", width = 15)
	@ApiModelProperty(value = "SEO关键字")
	private String seoKeywords;


	/**SEO描述*/
	@Excel(name = "SEO描述", width = 15)
	@ApiModelProperty(value = "SEO描述")
	private String seoDescription;

}
